//
//  NMainThreeImgCell.m
//  News
//
//  Created by zhangtao on 2018/10/7.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "NMainThreeImgCell.h"

@implementation NMainThreeImgCell

-(void)setModel:(NArticleModel *)model{
    NSString *img0 = [NSString stringWithFormat:@"%@%@",ImageUrl,model.coverPics.firstObject];
    NSString *img1 = [NSString stringWithFormat:@"%@%@",ImageUrl,model.coverPics[1]];
    NSString *img2 = [NSString stringWithFormat:@"%@%@",ImageUrl,model.coverPics[2]];

    _titleLab.text = model.Abstract;
    _themeNameLab.text = model.TopicalName;
    [_imgOne sd_setImageWithURL:[NSURL URLWithString:img0] placeholderImage:default_max_img];
    [_imgTwo sd_setImageWithURL:[NSURL URLWithString:img1] placeholderImage:default_max_img];
     [_imgThree sd_setImageWithURL:[NSURL URLWithString:img2] placeholderImage:default_max_img];
    _likeNumLab.text = [NSString stringWithFormat:@"%@",model.GoodNum];
    _commentNumLab.text = [NSString stringWithFormat:@"%@",model.CommentNum];
    _timeLab.text = model.CheckDate;

}

- (void)bindData:(MyFavoritesModel *)model
{
    NSArray *array = [model.coverPic componentsSeparatedByString:@","];
    self.titleLab.text = model.abstract;
    self.themeNameLab.text = model.topicalName;
    [self.imgOne sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ImageUrl,array[0]]] placeholderImage:[UIImage imageNamed:@"img"]];
    [self.imgTwo sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ImageUrl,array[1]]] placeholderImage:[UIImage imageNamed:@"img"]];
    [self.imgThree sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ImageUrl,array[2]]] placeholderImage:[UIImage imageNamed:@"img"]];
    self.likeNumLab.text = [NSString stringWithFormat:@"%@",@(model.goodNum)];
    self.commentNumLab.text = [NSString stringWithFormat:@"%@",@(model.commentNum)];
    self.timeLab.text = [ACEPublicTool timeIntervalChangeToNowTime:model.checkDate];
}

-(void)drawRect:(CGRect)rect{
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_imgOne.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft) cornerRadii:CGSizeMake(3,3)];//圆角大小
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = _imgOne.bounds;
    maskLayer.path = maskPath.CGPath;
    _imgOne.layer.mask = maskLayer;
    
    UIBezierPath *maskPath3 = [UIBezierPath bezierPathWithRoundedRect:_imgOne.bounds byRoundingCorners:(UIRectCornerTopRight | UIRectCornerBottomRight) cornerRadii:CGSizeMake(3,3)];//圆角大小
    CAShapeLayer *maskLayer3 = [[CAShapeLayer alloc] init];
    maskLayer3.frame = _imgOne.bounds;
    maskLayer3.path = maskPath3.CGPath;
    _imgThree.layer.mask = maskLayer3;
}

//-(void)layoutSubviews{
//    //TODO:uiview 单边圆角或者单边框
//
//}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

@end
